<?php
class ModelCategoryProductgroup extends Model 
{
	public function getList($where = "")
	{
		$query = $this->db->query("Select `product_group`.*, `product_brand`.brandname from `product_group`,`product_brand` where `product_group`.brandid = `product_brand`.brandid ".$where);
		return $query->rows;
	}
	
	public function getItem($groupid)
	{
		$query = $this->db->query("Select * from `product_group` where groupid = '".$groupid."'");
		return $query->row;
	}
	
	public function insert($data)
	{
		$brandid=$this->db->escape(@$data['brandid']);
		$groupname=$this->db->escape(@$data['groupname']);
		
		$field=array(
						'brandid',
						'groupname'
					);
		$value=array(
						$brandid,
						$groupname
					);
		return $this->db->insertData("product_group",$field,$value);
	}
	
	public function update($data)
	{
		$groupid=$this->db->escape(@$data['groupid']);
		$brandid=$this->db->escape(@$data['brandid']);
		$groupname=$this->db->escape(@$data['groupname']);
		
		$field=array(
						'brandid',
						'groupname'
					);
		$value=array(
						$brandid,
						$groupname
					);
					
		$where="groupid = '".$groupid."'";
		$this->db->updateData("product_group",$field,$value,$where);
	}	
			
	public function delete($groupid)
	{
		$groupid=$this->db->escape(@$groupid);
		$where="groupid = '".$groupid."'";
		$this->db->deleteData('product_group',$where);
	}
	
	public function deletes($data)
	{
		foreach($data as $groupid)
		{
			$this->delete($groupid);
		}		
	}
	
}

?>